package com.plian.system.controller.fr.financeindicators;

import com.plian.Tools.base.BaseController;
import com.plian.Tools.pagedata.PageData;
import com.plian.system.model.ListResult;
import com.plian.system.model.ObjResult;
import com.plian.system.service.fr.financeindicators.FinanceIndicatorsService;
import com.plian.system.service.fr.financeindicators.IFinanceIndicatorsSupplementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
/**
* 说明：值标定义表
* 创建时间:2020-06-06 11:21:04
*/
@RestController
@RequestMapping(value = "api/finance_indicators")
public class FinanceIndicatorsController extends BaseController {

	@Autowired
	private FinanceIndicatorsService financeindicatorsService;

	@Autowired
	private IFinanceIndicatorsSupplementService financeIndicatorsSupplementService;


	/**保存
	* @param
	* @throws Exception
	*/
	@PostMapping(value = "/save")
	public ObjResult save(@RequestBody PageData pd) throws Exception {
		return financeindicatorsService.save(pd);
	}
	/**修改
	* @param
	* @throws Exception
	*/
	@PostMapping(value = "/edit")
	public ObjResult edit(@RequestBody PageData pd) throws Exception {
		return financeindicatorsService.edit(pd);
	}

	/**
	* 根据id查询
	* @param pd
	* @return
	* @throws Exception
	*/
	@PostMapping(value = "/findbyid")
	public ObjResult findbyid(@RequestBody PageData pd) throws Exception {
		return financeindicatorsService.findbyid(pd);
	}
	/**
	 * 根据code查询
	 * @param pd
	 * @return
	 * @throws Exception
	 */
	@PostMapping(value = "/findcountbycode")
	public ObjResult findcountbycode(@RequestBody PageData pd) throws Exception {
		return financeindicatorsService.findcountbycode(pd);
	}
	/**
	* 根据集合删除数据
	* @param pd
	* @return
	* @throws Exception
	*/
	@PostMapping(value = "/del_ids")
	public ObjResult delids(@RequestBody PageData pd) throws Exception {
		return financeindicatorsService.del_ids((List<String>) pd.get("ids"));
	}

	/**
	* 查询列表
	* @return
	* @throws Exception
	*/
	@PostMapping(value = "/list")
	public ListResult listpage(@RequestBody PageData pd) throws Exception {
		return financeindicatorsService.listPage(pd);
	}
//	/** TODO DEL
//	 * 查询列表
//	 * @return
//	 * @throws Exception
//	 */
//	@PostMapping(value = "/findByDataSource")
//	public ListResult findByDataSource(@RequestBody PageData pd) throws Exception {
//		return financeindicatorsService.findByDataSource(pd);
//	}
	/**
	 * 查询预算表类型
	 * @return
	 * @throws Exception
	 */
	@PostMapping(value = "/findBudgetType")
	public ListResult findBudgetType(@RequestBody PageData pd) throws Exception {
		return financeindicatorsService.findBudgetType(pd);
	}

//	/**TODO DEL
//	 * 查询预算表类型
//	 * @return
//	 * @throws Exception
//	 */
//	@PostMapping(value = "/findByCodes")
//	public ListResult findByCodes() throws Exception {
//		return financeindicatorsService.findByCodes();
//	}

//	/** TODO DEL
//	 * 查询1-12月金额负数表类型（利润、现金流量净额）
//	 * @return
//	 * @throws Exception
//	 */
//	@PostMapping(value = "/findDeficitWarningType")
//	public ListResult findDeficitWarningTypeByCodes() throws Exception {
//		return financeindicatorsService.findDeficitWarningTypeByCodes();
//	}

	/**
	 * 查询
	 * @return
	 * @throws Exception
	 */
	@PostMapping(value = "/findFillDeviation")
	public ListResult findFillDeviation() throws Exception {
		return financeindicatorsService.findfilldeviation();
	}


	@GetMapping(value = "/init-by-year")
	public void initByYear(@RequestParam("year") int year){
		financeIndicatorsSupplementService.init(year);
	}
}
